package top.wugy.blog.searcher;

import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import top.wugy.blog.model.TBlog;

/**
 * wugy on 2017/11/15 10:32
 */
public class SearcherKit {

    private static ISearcher mSearcher;

    public static void init(ISearcher searcher) {
        mSearcher = searcher;
        if (null == mSearcher)
            throw new RuntimeException("must init searcher before, please invoke SearchFactory.use() to init.");
    }

    public static Page<Record> search(int pageNum, int pageSize, String keyword) {
        return mSearcher.search(pageNum, pageSize, keyword);
    }

    public static void reloadIndex() {
        mSearcher.reloadIndex();
    }

    public static void addRecord(SearcherBean bean) {
        mSearcher.addRecord(bean);
    }

    public static void updateRecord(SearcherBean bean) {
        mSearcher.updateRecord(bean);
    }
}
